From 4f2a113ba67dbdae178b2beb12a39dbaf0e70ff6 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Thu, 7 Dec 2006 17:47:43 +0000 Subject: [PATCH] Diagnose bad config files. Signed-off-by: Ewan Mellor --- tools/python/xen/xm/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py index 9151848d30..6850061908 100644 --- a/tools/python/xen/xm/main.py +++ b/tools/python/xen/xm/main.py @@ -335,17 +335,22 @@ all_commands = (domain_commands + host_commands + scheduler_commands + # Configuration File Parsing ## +config = None if os.path.isfile(XM_CONFIG_FILE): - config = xml.dom.minidom.parse(XM_CONFIG_FILE) -else: - config = None + try: + config = xml.dom.minidom.parse(XM_CONFIG_FILE) + except: + print >>sys.stderr, ('Ignoring invalid configuration file %s.' % + XM_CONFIG_FILE) def parseServer(): if config: server = config.getElementsByTagName('server') if server: st = server[0].getAttribute('type') - if st != SERVER_XEN_API: + if st != SERVER_XEN_API and st != SERVER_LEGACY_XMLRPC: + print >>sys.stderr, ('Invalid server type %s; using %s.' % + (st, SERVER_LEGACY_XMLRPC)) st = SERVER_LEGACY_XMLRPC return (st, server[0].getAttribute('uri')) -- 2.30.2